

export default class orc_data{ 

    public static local_data:local_data = {  
        energy_life:"10",           //体力值
        energy_time:0,              //体力恢复时间
        tips_num:"0",               //提示使用次数
        energy_buy:"cmd",           //购买体力次数 
        voice_switch:true,          //声音开关
        tips_time:"0",              //使用道具的时间戳 
    }    

    public static memory_data:memory_data = {
        user_id:'cmd',
        user_guest:true,
        token:'',
        user_info:{},
        obstacle_conf:{},
        level_conf:{},
        extra_socre:0,
        extra_energy:0,
        go_friend:'',
    }   

    

    public static save_local_data(){
        
        let save_data:any = {};
        let session_key =  "orc_" + orc.orc_config.PLATFORM + "_" + orc.orc_config.GAME_NAME;
        save_data[session_key] = {};
        //console.log('session_key',session_key);

        for (const key in orc.orc_data.local_data) {            
            save_data[session_key][key] = orc.orc_data.local_data[key];
        }
        //console.log("save_local_data:",save_data);
        cc.sys.localStorage.setItem(session_key,JSON.stringify(save_data[session_key]));
    }

    public static async load_local_data(){
        let session_key =  "orc_" + orc.orc_config.PLATFORM + "_" + orc.orc_config.GAME_NAME;
        let local_data_temp = await cc.sys.localStorage.getItem(session_key);   
        if(local_data_temp == "" || local_data_temp == null)
        {
            //数据为空
            //console.log('load_local_data数据为空',session_key,local_data_temp); 
        } 
        else
        {
            let local_data = JSON.parse(local_data_temp);      
            //console.log("load_local_data:",local_data); 
            //讲本地的数据存入到local_data里去
            for (const key in orc.orc_data.local_data) {
                if(local_data[key])
                {
                    orc.orc_data.local_data[key] = local_data[key];
                }                
            }    
        }
    }

    public static log_local_data(){
        for (const key in orc.orc_data.local_data) {            
            //console.log('log_local_data',key,orc.orc_data.local_data[key]);                           
        }    
    }

}
